package sortSentence;

import java.util.Arrays;
import java.util.Comparator;

public class Solution {
    public String sortSentence(String s) {
        //
        String[] words = s.split(" ");
        Arrays.sort(words, (o1, o2) -> o1.charAt(o1.length()-1)-o2.charAt(o2.length()-1));
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < words.length; i++) {
            //
            sb.append(words[i].substring(0,words[i].length()-1)).append(" ");
        }
        return sb.substring(0,sb.length()-1);
    }
}
